<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>层次选择器</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
        body{
            width: 300px;
            margin: 0 auto;
        }
        div{
            border:1px solid #ccc;
            margin: 5px;
            padding: 5px;
        }
        div div{/*后代选择器*/
            background: orange;
        }
        body>div{/*子元素-选择器*/
            background: green;
        }
        .active+div{/*相邻兄弟选择器*/
            background: lime;
        }
        .active~div{/*通用兄弟选择器*/
            background: red;
        }
    </style>
</head>
<body>
<div class="active">1</div>
<div>2</div>
<div>3</div>
<div>4
    <div>5</div>
    <div>6</div>
</div>
<div>7
    <div>8
        <div>9
            <div>10</div>
        </div>
    </div>
</div>
</body>
</html>